package com.restaurant.serviceimpl;

import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.restaurant.domain.Menusize;
import com.restaurant.service.MenusizeService;

public class MenusizeServiceImpl implements MenusizeService {

   private HibernateTemplate hibernateTemplate;

   @Autowired
   public void setSessionFactory(SessionFactory sessionFactory){
       this.hibernateTemplate = new HibernateTemplate(sessionFactory);
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Menusize addOrModify( Menusize objMenusize ) {
       return ( Menusize ) hibernateTemplate.merge( objMenusize );
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Menusize deleteRecord( Menusize objMenusize ) {
       hibernateTemplate.delete( objMenusize );
       return objMenusize;
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Menusize modifyRecord( Menusize objMenusize ) {
       return ( Menusize ) hibernateTemplate.merge( objMenusize );
   }

   @SuppressWarnings("unchecked")
   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public List<Menusize> loadAll() {
       return (List<Menusize>)hibernateTemplate.findByNamedQuery( "Menusize.findAll");
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Menusize loadByPrimaryKey( Long primaryKey ) {
       return (Menusize) hibernateTemplate.get( Menusize.class, primaryKey );
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Menusize deleteByPrimaryKey( Long primaryKey ) {
       return deleteRecord(loadByPrimaryKey(primaryKey));
   }

   @SuppressWarnings("unchecked")
   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public List<Menusize> loadByHql(String query) {
       return ( List<Menusize> ) hibernateTemplate.find( query );
   }
}